<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<%@include file="/WEB-INF/common/taglibs.jsp"%>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css" href="${ctx}resources/css/list.css" />
		<script type="text/javascript" src="${ctx}resources/js/page.js"></script>
		<script type="text/javascript" src="${ctx}resources/js/table.js"></script>
		<script type="text/javascript" src="${ctx}resources/js/um.js"></script>
		<title>江苏龙芯梦兰科技股份有限公司-SMT生产管理系统</title>
	</head>
	
	<script type="text/javascript">
		function start(order,status){
			if("0"!=status){
				alert("订单已经开始了！");
				return;
			}
			if(!confirm("订单开始就不能修改和删除，是否开始订单?")){
				return ;
			}
			$.ajax({ 
		      url: "${ctx}order/start.htm", 
		      global: false, 
		      type: "POST", 
		      data: ({"order" :order}), 
		      dataType: "json", 
		      async:false, 
		      success: function(data){ 
		         if(data.msg=="Y"){
		        	 alert("订单操作成功!");
		         }
	     	 }
	  		 });
			 $("#mainForm").submit();
	}
		function endOrder(id){
			if(!confirm("结单前请确认订单生产完成?")){
				return ;
			}
			$.ajax({ 
		      url: "${ctx}order/endOrder.htm", 
		      global: false, 
		      type: "POST", 
		      data: ({"id" :id}), 
		      dataType: "json", 
		      async:false, 
		      success: function(data){ 
		         if(data.msg=="Y"){
		        	 alert("订单结单成功!");
		         }else{
		        	 alert("订单尚未生产完成，暂不能结单!");
		         }
	     	 }
	  		 });
			 $("#mainForm").submit();
	}
	</script>
	<body>
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
			<form id="mainForm" action="${ctx}order/list.htm" method="post">
				<input type="hidden" name="page.pageNo" id="pageNo" value="${page.pageNo}" />
				<input type="hidden" name="page.orderBy" id="orderBy" value="id" />
				<input type="hidden" name="page.order" id="order" value="asc" />
				<tr>
					<td height="30">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td height="24" bgcolor="#353c44">
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td>
												<table width="100%" border="0" cellspacing="0" cellpadding="0">
													<tr>
														<td width="6%" height="19" valign="bottom"> <div align="center"> <img src="${ctx}resources/images/tb.gif" width="14" height="14" /> </div></td>
														<td width="94%" valign="bottom"> <span class="STYLE1"> 订单基本信息列表</span> </td>
													</tr>
												</table>
											</td>
											<td>
												<div align="right">
													<span class="STYLE1"> 
														<smt:verify authority="order_add"><span id="add" url="order" style="cursor: pointer;"><img src="${ctx}resources/images/add.gif" width="10"height="10" />添加 &nbsp;</span></smt:verify>
													</span>
												</div>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>
						<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
							<tr style="padding-top: 2px">
								<td class="STYLE19" bgcolor="#FFFFFF" colspan="16">
									<span style="padding-left: 40px;">订单号:<input type="text" name="filter_LIKES_orderNo" value="${param['filter_LIKES_orderNo']}" style="width: 80px"> </span>
									<span style="padding-left: 40px;">产品名称:<input  type="text" name="filter_LIKES_productName" value="${param['filter_LIKES_productName']}" style="width: 80px"> </span>
									<span style="padding-left: 40px;">成品料号:<input  type="text" name="filter_LIKES_finishedPartNo" value="${param['filter_LIKES_finishedPartNo']}" style="width: 80px"> </span>
									<span style="padding-left: 20px">状态: <select name="filter_EQS_status">
											<option value=""> 全部 </option>
											<option value="0" ${param['filter_EQS_status']=='0'?"selected":""}> 未开始 </option>
											<option value="1" ${param['filter_EQS_status']=='1'?"selected":""}> 已开始</option>
											<option value="1" ${param['filter_EQS_status']=='2'?"selected":""}> 已结单</option>
										</select> </span>
									<span style="padding-left: 20px"><input type="button"
											name="" onclick="search();" value="查询"> </span>
								</td>
							</tr>
							<tr>
								<td width="5%" height="20" bgcolor="d3eaef" class="STYLE10">
									<div align="center">
										<input type="checkbox" name="checkbox" id="checkall"/>
									</div>
								</td>
								<td height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">订单号</span>
									</div>
								</td>
								<td  height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">产品名称</span>
									</div>
								</td>
								<td  height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">订单数量</span>
									</div>
								</td>
								<td  height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">每箱数量</span>
									</div>
								</td>
								<td  height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">成品料号</span>
									</div>
								</td>
								<td  height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">PMON版本</span>
									</div>
								</td>
								<td height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">录入人员</span>
									</div>
								</td>
								<td  height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">需求日期</span>
									</div>
								</td>
								<td  height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">开工日期</span>
									</div>
								</td>
								<td height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">完工日期</span>
									</div>
								</td>
								<td  height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">良率</span>
									</div>
								</td>
								<td  height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">不良数量</span>
									</div>
								</td>
								<td  height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">完成数量</span>
									</div>
								</td>
								<td  height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">状态</span>
									</div>
								</td>
								<td height="20" bgcolor="d3eaef" class="STYLE6">
									<div align="center">
										<span class="STYLE10">基本操作</span>
									</div>
								</td>
							</tr>
							<c:forEach items="${page.result}" var="entity">
								<tr style="background-color: ">
									<td height="20" bgcolor="#FFFFFF">
										<div align="center">
											<input type="checkbox" name="objId" value="${entity.id}"/>
										</div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE6">
										<div align="center">
											<span class="STYLE19">${entity.orderNo}</span>
										</div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center">
											${entity.productName}
										</div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center"> ${entity.num} </div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center"> ${entity.packsize} </div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center"> ${entity.finishedPartNo} </div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center"> ${entity.pmonVersion} </div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center"> ${entity.orderUser.realName} </div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center"> <fmt:formatDate value="${entity.requireDate}" pattern="yyyy-MM-dd"/>
										</div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center"> <fmt:formatDate value="${entity.startDate}" pattern="yyyy-MM-dd"/> </div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center"> <fmt:formatDate value="${entity.endDate}" pattern="yyyy-MM-dd"/> </div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center"><fmt:formatNumber value="${entity.through/entity.num*100}" pattern="##.##"/>%</div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center">${entity.badNum}</div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center">${entity.completeNum}</div>
									</td>
									<td height="20" bgcolor="#FFFFFF" class="STYLE19">
										<div align="center"> ${entity.status=='0'?"未开始":entity.status=='1'?"已开始":entity.status=='2'?"已结单":""} </div>
									</td>
									<td height="20" bgcolor="#FFFFFF">
										<div align="center" class="STYLE21">
										    <c:if test="${entity.status=='0'}">
											<smt:verify authority="order_start"><a href="javascript:start('${entity.id}','${entity.status}')">开始</a>|</smt:verify> 
										    </c:if>
										    <c:if test="${entity.status=='0'}">
											 <smt:verify authority="order_delete">
											 <a href="javascript:if(confirm('确认要删除吗？')){window.location.href='${ctx}order/delete.htm?ids=${entity.id}';}">删除</a> | </smt:verify>
											<smt:verify authority="order_modify"><a href="${ctx}order/modify.htm?id=${entity.id}">修改</a></smt:verify>
											</c:if>
										    <c:if test="${entity.status!='0'}">
												 <smt:verify authority="order_view"><a href="${ctx}order/order.htm?id=${entity.id}"  style="text-decoration: none">查看</a></smt:verify>
											</c:if>
										    <c:if test="${entity.status=='1'&&entity.pack}">
												 <smt:verify authority="order_end"><a onclick="endOrder('${entity.id}')" style="text-decoration: none;cursor: pointer;">结单</a></smt:verify>
											</c:if>
										</div>
									</td>
								</tr>
							</c:forEach>
						</table>
					</td>
				</tr>
				<tr>
					<td height="30">
						<%@include file="/WEB-INF/common/footer.jsp"%>
					</td>
				</tr>
			</form>
		</table>
	</body>
</html>